Skip to content

Conversation

@The-Code-Monkey
Copy link

@The-Code-Monkey The-Code-Monkey commented Jan 22, 2026

Summary by CodeRabbit

  • New Features
    • Crushers now support dual outputs: a primary result plus an optional auxiliary item per cycle.
    • Recipes can declare an optional auxiliary result alongside the primary output.
    • Crusher UI shows a second read-only output slot to display auxiliary items.
    • Crafting and extraction updated so both outputs are produced, merged into stacks when possible, stored, and retrievable.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

Warning

Rate limit exceeded

@The-Code-Monkey has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 46 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

Crusher now supports an optional auxiliary output: inventory expanded to four slots, crafting validates and writes primary and optional auxiliary outputs to separate output slots, extraction and slot access updated, and the UI shows a read-only auxiliary output slot.

Changes

Cohort / File(s) Change Summary
Block Entity Core Logic
src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java
Inventory size increased 3→4 with new AUXILIARY_OUTPUT_SLOT. Added canInsertIntoSlot(int, ItemStack) and insertOrIncrement(int, ItemStack). canCraft() checks both outputs; craftItem() writes primary to OUTPUT_SLOT and optional auxiliary to AUXILIARY_OUTPUT_SLOT. getAvailableSlots(...) and canExtract() expose and allow extraction from the auxiliary slot. toUpdatePacket() now returns a proper update packet.
Recipe Definition
src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java
CrusherRecipe record extended to include Optional<ItemStack> auxiliaryOutput. Added null-safe initializer, a 3-arg delegating constructor, updated getIngredients(), and extended Serializer.CODEC and STREAM_CODEC to (de)serialize optional auxiliary_output.
Screen Handler UI
src/main/java/anya/pizza/houseki/screen/custom/CrusherScreenHandler.java
Inventory check updated to 4 slots. Added a read-only auxiliary output slot at index 3 (position 130,30) alongside existing output slot; constructor sync/properties updated.
Data / Recipes
src/main/resources/data/houseki/recipe/crushed_bauxite_from_crushing_bauxite.json
Recipe JSON now includes auxiliary_result (e.g., minecraft:iron_nugget) producing an optional secondary output.

Sequence Diagram

sequenceDiagram
    participant Tick as Game Tick
    participant BlockEnt as CrusherBlockEntity
    participant Recipe as CrusherRecipe
    participant Inv as Inventory

    Tick->>BlockEnt: tick() / canCraft()
    BlockEnt->>Recipe: findMatching(input)
    Recipe-->>BlockEnt: primary(ItemStack), Optional(auxiliary)
    BlockEnt->>BlockEnt: canInsertIntoSlot(OUTPUT_SLOT)
    BlockEnt->>BlockEnt: canInsertIntoSlot(AUXILIARY_OUTPUT_SLOT)
    alt Both slots can accept
        BlockEnt->>Inv: craftItem()
        Inv->>Inv: insertOrIncrement(OUTPUT_SLOT, primary)
        opt auxiliary present
            Inv->>Inv: insertOrIncrement(AUXILIARY_OUTPUT_SLOT, auxiliary)
        end
        Inv-->>BlockEnt: outputs stored
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped by the crusher with a curious nose,
One grind, then two gifts in neat little rows.
Primary snug, aux tucked in the bin,
I thumped for joy — double treats, double grin. 🎋

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Feat/add optional second item' clearly and specifically describes the main change: adding optional secondary/auxiliary output functionality to the crusher block.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java (1)

234-236: Auxiliary output slot not exposed to hoppers.

getAvailableSlots() only returns OUTPUT_SLOT for Direction.DOWN, but canExtract() allows extraction from both output slots. This means hoppers below the crusher cannot extract items from the auxiliary output slot.

If this is intentional, consider adding a comment. Otherwise, update to expose both slots:

Proposed fix (if hoppers should extract from both slots)
 `@Override`
 public int[] getAvailableSlots(Direction side) {
-    return side == Direction.DOWN ? new int[]{OUTPUT_SLOT} : new int[]{INPUT_SLOT, FUEL_SLOT};
+    return side == Direction.DOWN ? new int[]{OUTPUT_SLOT, AUXILARY_OUTPUT_SLOT} : new int[]{INPUT_SLOT, FUEL_SLOT};
 }
src/main/java/anya/pizza/houseki/screen/custom/CrusherScreenHandler.java (1)

29-29: Inventory size check is outdated.

The inventory now has 4 slots, but checkSize still validates for 3. This should be updated to match the new inventory size.

Proposed fix
-        checkSize((Inventory) blockEntity, 3);
+        checkSize((Inventory) blockEntity, 4);
🤖 Fix all issues with AI agents
In
`@src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java`:
- Around line 194-199: The canInsertIntoSlot method currently uses
slotStack.getMaxCount() even when slotStack is empty, which incorrectly uses the
default 64; change the logic to compute the allowed max using the incoming
stack's max when the slot is empty. Specifically, in canInsertIntoSlot(int slot,
ItemStack stack) determine int max = slotStack.isEmpty() ? stack.getMaxCount() :
slotStack.getMaxCount() and use that max in the count comparison
(slotStack.getCount() + stack.getCount() <= max), keeping the existing
equality/emptiness checks for slotStack and stack.

In `@src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java`:
- Around line 89-91: The CODEC mapping in CrusherRecipe currently wraps
ItemStack.EMPTY into Optional.of, causing auxiliaryOutput to be present for
missing fields; change the xmap to produce Optional.empty() when the read
ItemStack is ItemStack.EMPTY and to write ItemStack.EMPTY when the Optional is
empty (i.e. replace Optional::of with a function that returns item.isEmpty() ?
Optional.empty() : Optional.of(item), and keep the writer as opt ->
opt.orElse(ItemStack.EMPTY)) so auxiliaryOutput correctly reflects an absent
auxiliary_result.
🧹 Nitpick comments (2)
src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java (1)

67-70: Redundant getter for record component.

Java records auto-generate an accessor method auxiliaryOutput() for each component. This explicit getAuxiliaryOutput() method duplicates that functionality. Consider removing it and using the canonical auxiliaryOutput() accessor throughout the codebase for consistency.

src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java (1)

42-42: Typo: AUXILARY should be AUXILIARY.

The constant name has a spelling error. Consider renaming for consistency.

Proposed fix
-    private static final int AUXILARY_OUTPUT_SLOT = 3;
+    private static final int AUXILIARY_OUTPUT_SLOT = 3;

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java (1)

234-237: Auxiliary output slot is not accessible for hopper extraction.

canExtract() correctly allows extraction from both output slots (line 249), but getAvailableSlots() only exposes OUTPUT_SLOT for the DOWN direction. Hoppers won't be able to pull items from the auxiliary slot because it's not listed in the available slots array.

Proposed fix
     `@Override`
     public int[] getAvailableSlots(Direction side) {
-        return side == Direction.DOWN ? new int[]{OUTPUT_SLOT} : new int[]{INPUT_SLOT, FUEL_SLOT};
+        return side == Direction.DOWN ? new int[]{OUTPUT_SLOT, AUXILARY_OUTPUT_SLOT} : new int[]{INPUT_SLOT, FUEL_SLOT};
     }
🧹 Nitpick comments (2)
src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java (2)

42-42: Typo in constant name: AUXILARYAUXILIARY.

The constant name is misspelled. Consider fixing for consistency and readability.

Suggested fix
-    private static final int AUXILARY_OUTPUT_SLOT = 3;
+    private static final int AUXILIARY_OUTPUT_SLOT = 3;

Note: Update all references throughout the file accordingly.


206-214: Use consistent accessor method for recipe output in both canCraft() and craftItem().

canCraft() uses crusherRecipe.getResult(null) (line 188) while craftItem() uses crusherRecipe.output() (line 209). Both access the same ItemStack, so using the same accessor method in both places improves code clarity and maintainability.

Consider standardizing on a single accessor method:

Suggested fix
         private void craftItem() {
             Optional<RecipeEntry<CrusherRecipe>> recipe = getCurrentRecipe();
             if (recipe.isEmpty()) return;
 
             CrusherRecipe crusherRecipe = recipe.get().value();
 
             // Handle Main Output
-            insertOrIncrement(OUTPUT_SLOT, crusherRecipe.output().copy());
+            insertOrIncrement(OUTPUT_SLOT, crusherRecipe.getResult(null).copy());
             
             // Handle Auxiliary Output
             crusherRecipe.getAuxiliaryOutput().ifPresent(stack -> {
                 insertOrIncrement(AUXILARY_OUTPUT_SLOT, stack.copy());
             });

@The-Code-Monkey
Copy link
Author

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

✅ Actions performed

Full review triggered.

@The-Code-Monkey
Copy link
Author

@coderabbitai generate docstrings

@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

✅ Actions performed

Initiated docstring generation; will generate only if new commits exist.

@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #2

@The-Code-Monkey
Copy link
Author

@coderabbitai resolve

Docstrings generation was requested by @The-Code-Monkey.

* #1 (comment)

The following files were modified:

* `src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java`
* `src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java`
* `src/main/java/anya/pizza/houseki/screen/custom/CrusherScreenHandler.java`
…1e6c9

📝 Add docstrings to `feat/add-optional-second-item`
@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

✅ Actions performed

Comments resolved.

@The-Code-Monkey
Copy link
Author

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

✅ Actions performed

Full review triggered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants